<?php $this->load->view('header') ?>

<div id="content">
<div class="column full fl">
		
		<div class="box">
		<div class="box-header">Daftar Rekam Medis</div>
		<div class="box-content box-table">
		<br />
		
        	<?php if (isset($errorMessage)) : ?>
            	<div class="notification <?php echo ((isset($isSuccess) && $isSuccess) ? 'success' : 'error');?>"><?php echo $errorMessage; ?></div>
	        <?php endif; ?>    	
	        <br />
	        
	        <?php  echo form_open('klinik/rekamMedis/view/',array('name'=>'formRekamMedis','id'=>'formRekamMedis','class'=>'frModalLoad'),array('kirim'=>'kirim')); ?>
		        &nbsp;&nbsp;&nbsp;&nbsp;
		        
		        Tanggal &nbsp;&nbsp;&nbsp; 
		        <?php echo form_input(array('name'=>'frdate','value'=>$frdate == 'all' ? '' : $frdate, 'class'=> 'form-field date', 'readonly'=>'readonly', 'style'=>'width:80px'));?>
		        - 
		        <?php echo form_input(array('name'=>'todate','value'=>$todate == 'all' ? '' : $todate, 'class'=> 'form-field date', 'readonly'=>'readonly', 'style'=>'width:80px'));?>

		        <?php if($frdate != 'all' || $todate != 'all'):?>
		        	<?php echo anchor('klinik/rekamMedis/view', '<b>Clear Date</b>' , 'style="color:red"')?>
		        <?php endif;?>
		        <br />
		        
		        &nbsp;&nbsp;&nbsp;&nbsp;
		        Pasien &nbsp;&nbsp;&nbsp;&nbsp;  
		        <select name='pasienId' id='pasienId'>
					<option value='all'>Semua Pasien</option>	       
			        <?php if($listPasien) foreach($listPasien as $row):?>
			        	<option value='<?php echo $row['pasienId'];?>' <?php echo get_data($uri_to_assoc,'pasienId') == $row['pasienId'] ? 'selected="selected"' : '';?>>
			        		<?php echo $row['pasienNama'];?>
			        	</option>	 
			        <?php endforeach;?>
		        </select>
 
 				&nbsp;&nbsp;
		        <?php echo form_submit('submit','Cari', 'class="button themed"');?>
		        
			<?php echo form_close();?>
	        <br />
	        
            <?php echo $paging?>
            <table class="tablebox">
            <thead class="table-header" style="border-top:1px solid #ccc;border-bottom:1px solid #ccc">
                <tr>
                	<th width="10">No</th>
                    <th>Tanggal</th>
                    <th>Waktu</th>
                    <th>RM Kode</th>
                    <th>Nama</th>
                    <th>Jenkel</th>
                    <th>Usia</th>                    
                    <th>Total Biaya</th>
                    <th width="150">Action</th>
                </tr>
            </thead>
            <tbody>
            	<?php $totalPayment = 0;?>
            	
            	<?php $no = get_data($uri_to_assoc,'page') + 1;?>
                <?php if ($dataView) foreach($dataView as $key=>$row) : ?>
                <?php $class = $no % 2 == 0 ? 'even' : 'odd' ?>
                <tr class=<?php echo $class?>>
                	<td><?php echo $no?></td>
                		
                	<!-- Date -->
                	<?php if($key > 0):?>
                		<td><?php echo mydate($dataView[$key-1]['rmTglMulai']) == mydate($row['rmTglMulai']) ? '' : mydate($row['rmTglMulai'])?></td>
                	<?php else:?>
                    	<td><?php echo mydate($row['rmTglMulai'])?></td>
                    <?php endif;?>
                    
                    <td><?php echo mytime($row['rmTglMulai']);?></td>
                    
                    <td><?php echo get_data($row,'rmKode');?></td>
                    <td><?php echo get_data($row,'pasienNama')?></td>
                    <td><?php echo get_data($row,'pasienJenKel')?></td>
                    <td><?php echo getUsia( get_data($row,'pasienTglLahir') )?></td>
                    
                    <td>Rp. <span style="float:right;"><?php echo number_format( get_data($row,'rmTotalBiaya') )?></span></td>
                    <?php $totalPayment = $totalPayment + get_data($row,'rmTotalBiaya');?>
                    
                    <td>
                        <?php //echo anchor('klinik/registrasi/proses/from/rekamMedis/id/' . $row['rmId'], '<span class="icon_text save"></span>RM', 'class="button white"');?>
                        
                        <?php echo anchor('klinik/registrasi/preview/from/rekamMedis/id/' . $row['rmId'], 'cetak', 'class="button white"');?>
                    		
                        <?php //echo isAccess('klinik','rekammedis','delete') ? anchor('klinik/rekamMedis/view/pasienId/'.get_data($uri_to_assoc,'pasienId').'/frdate/'.get_data($uri_to_assoc,'frdate').'/todate/'.get_data($uri_to_assoc,'todate').'/action/delete/id/' . $row['rmId'],'<span class="icon_text cancel"></span>Hapus', array('onClick' => "return confirm('".$this->lang->line('global_confirm_delete')."')" , 'class' => "button white")) : ''?>
                    </td>
                </tr>
                <?php $no++?>
                <?php endforeach;?>
                
                <!-- Total Payment -->
                <?php $class = $no % 2 == 0 ? 'even' : 'odd' ?>
                <tr class=<?php echo $class?>>
                	<td></td><td></td><td></td><td></td>
                	<td></td><td></td><td></td>
                	<td style='font-weight:bold;font-size:15px;'>
                		Rp. <span style="float:right;"><?php echo number_format($totalPayment)?></span>
                	</td>
                	<td></td>
                </tr>
                <!-- End -->
                
            </tbody>
            </table>
            <div id="paging">
            <?php echo $paging?>
            </div>
		</div>
		</div>
	
	</div>

<script type="text/javascript">
<!--
jQuery(document).ready(function($){
	//Date
	$('.date').datepicker({
	   yearRange: "-10:+10",
	   dateFormat: 'yy-mm-dd',
	   maxDate: 'd', 
	   showButtonPanel: true,
	   changeMonth: true,
	   changeYear: true
	});
});
//-->
</script> 
<?php $this->load->view('footer') ?>